<?php
include "cache";

$link = 'no posts found D;';
$ts = 0;
$posts_watched = 0;

foreach ($boards as $board) {
    foreach ($board['pages'] as $page) {
        foreach ($page['threads'] as $thread) {
            foreach ($thread['posts'] as $post) {
                if ($post['trip'] == $_POST['keyword'] && $post['date'] > $ts) {
                    $link = "<a href=\"http://chan.catiewayne.com/"
                           ."{$board['name']}/res/{$thread['number']}.html"
                           ."#{$post['number']}\" target=\"_blank\" "
                           ."title=\"Will open in new tab/window\">"
                           ."&gt;&gt;&gt;/{$board['name']}/"
                           ."{$post['number']}</a>";
                    $ts = $post['date'];
                }
                $posts_watched++;
            }
        }
    }
}

echo "<html>
<head>
    <title>Catie Checker v2</title>
    <meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">
    <link rel=\"icon\" type=\"image/png\" href=\"favicon.png\">
    <style type=\"text/css\">
        a:link {color:#B6FF00;}
        a:hover {color:#B6FF00;}
        a:active {color:#B6FF00;}
        a:visited {color:#4A5B20;}
    </style>
</head>
<body style=\"background-color:black;
              color:white;\">
    Last founded post in cache: $link<br>
    Searched in $posts_watched posts.<br>
    <br>
    <a href=\"http://sorc.dyndns-home.com/cc2/\">Home</a>
</body>
</html>";

exit(0);
?>
